<?php
defined('ANT_ACCESS') or die('Access denided');
/**
 * Ant Framework
 *
 * An open source application development framework for PHP 5
 *
 * @package		Ant Framework
 * @author		Meshin Dmitriy
 * @copyright	Copyright (c) 2008, Meshin Dmitriy
 * @license		GNU Public Lisence v2
 * @link		http://code.google.com/p/ant-framework
 * @desc		hook class
 **/
class ANT_hooks{
	protected $hooks = array();
	protected $objects = array();

	function __construct(){
		require_once(get_folder('configs').'hooks'.EXT);
		$this->hooks =& $hooks;
	}
	
	public function hook($type){
		foreach($this->hooks[$type] as $hook){
			require_once($hook['file']);
			if(!isset($this->objects[$hook['class']])){
				$this->objects[$hook['class']] =& new $hook['class'];
			}
			if(is_callable(array(&$this->objects[$hook['class']], $hook['function']))){
				call_user_func_array(array(&$this->objects[$hook['class']], $hook['function']), $hook['params']);
			}
		}
	}
	
	public function &get_object($class){
		if(isset($this->objects[$class])){
			return $this->objects[$class];
		}
		else return FALSE;
	}
}
?>